import { createRouter, createWebHashHistory } from 'vue-router'
import layout from '@/views/layout.vue'

export const pageList = [
  {
    path: '/home',
    name: 'home',
    component: () => import('@/views/home/index.vue'),
    meta: { title: '项目' }
  },
  {
    path: '/serversAdmin',
    name: 'serversAdmin',
    component: () => import('@/views/serversAdmin.vue'),
    meta: { title: '服务器' }
  },
  {
    path: '/setting',
    name: 'setting',
    component: () => import('@/views/setting.vue'),
    meta: { title: '设置' }
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes: [
    {
      path: '/',
      redirect: '/home'
    },
    {
      path: '/layout',
      name: 'layout',
      redirect: '/home',
      component: layout,
      meta: { title: '布局' },
      children: pageList
    },
    {
      path: '/deployHistory',
      name: 'deployHistory',
      component: () => import('@/views/deployHistory.vue'),
      meta: { title: '部署历史' }
    },

    // Resolve refresh page, route warnings
    {
      path: '/:pathMatch(.*)*',
      component: () => import('@/components/404.vue')
    }
  ],
  strict: false,
  scrollBehavior: () => ({ left: 0, top: 0 })
})

export default router
